package com.neusoft.neuiotms.dcam.fixed.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.neuiotms.dcam.fixed.model.enums.InventoryDutyResultStatus;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@Table(name = "neuiot_inventory_result")
@org.hibernate.annotations.Table(appliesTo = "neuiot_inventory_result", comment = "盘点结果表")
public class InventoryResult extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @NotBlank(message = "资产名不能为空")
    @Length(max = 255, message = "资产名不能超过{max}位")
    @Column(length = 255, nullable = false)
    private String name;

    @Length(max = 255, message = "固资编号不能超过{max}位")
    @Column(length = 255, nullable = false)
    private String code;

    /** 序列号 */
    private String serialnumber;

    @NotNull(message = "资产类型（小分类）不能为空")
    @ManyToOne
    private AssetType type;
    /** 合同编码（复制想） */
    private String contractNo;
    /** 位置编码（复制想） */
    private String locationCode;
    /** 位置名称（复制想） */
    private String locationName;

    @NotNull(message = "资产状态不能为空")
    @Column(length = 255, nullable = false)
    private String status = "idle";

    /** 使用人用户名 */
    @Column(length = 20, nullable = true)
    private String userId;

    /** 使用人姓名 */
    @Length(max = 255, message = "使用人姓名不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String userName;

    /** 使用部门 */
    @Length(max = 255, message = "使用部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String orgId;

    /** 使用部门名称 */
    @Length(max = 255, message = "使用部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String orgName;

    /** 变更使用人ID */
    @Column(length = 20, nullable = true)
    private String updateUserId;

    /** 变更使用人姓名 */
    @Length(max = 255, message = "使用人不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String updateUserName;

    /** 变更使用部门 */
    @Length(max = 255, message = "使用部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String updateOrgCode;

    /** 变更使用部门名称 */
    @Length(max = 255, message = "使用部门不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String updateOrgName;

    /** 变更位置编码 */
    private String updateLocationCode;

    /** 变更位置名称 */
    private String updateLocationName;

    /** 盘点备注 */
    @Column(length = 225, nullable = true)
    private String note;

    /** 资产id */
    @Column(nullable = true)
    private Long assetId;

    /** 盘点结果状态 */
    @Enumerated(EnumType.STRING)
    @NotNull(message = "盘点结果状态不能为空")
    private InventoryDutyResultStatus dutyResultStatus = InventoryDutyResultStatus.wait;

    /** 关联盘点任务 */
    @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST }, fetch = FetchType.LAZY)
    InventoryDuty inventoryDuty;

}
